<?php


namespace common\validate;

class TaskRepairOrder extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Create 验证场景定义
    public function sceneCreate(): TaskRepairOrder
    {
        return $this->append("data", "require|array")
            ->append("data.task_id", "require|integer")
            ->append('data.repair_step_category_id', 'require|integer')
            ->append('data.effect_task_number', 'require|integer')
            ->append('data.repair_reason', 'require');
    }

    // Update 验证场景定义
    public function sceneUpdate(): TaskRepairOrder
    {
        return $this->append("data", "require|array")
            ->append("data.id", "require|integer");
    }

    // Select 验证场景定义
    public function sceneSelect(): TaskRepairOrder
    {
        return $this->append('param', 'array')
            ->append('param.page', 'array');
    }

    // Start 验证场景定义
    public function sceneStart(): TaskRepairOrder
    {
        /**
         * 跨环节返修 提供返修单,返修任务id
         *
         * 组内返修 直接指定任务id
         */
        return $this
            ->append('param', 'require')
            ->append('param.id', 'requireIf:param.type,cross_group')
            ->append('param.task_id', 'require')
            ->append('param.need_repair_task_id', 'require');
    }

    // GetByTaskId 验证场景定义
    public function sceneGetByTaskId(): TaskRepairOrder
    {
        return $this->append('param.task_id', 'require|integer');
    }

    // GetRepairStepCategory 验证场景定义
    public function sceneGetRepairStepCategory(): TaskRepairOrder
    {
        return $this->append('param.task_id', 'require');
    }

    // GetEntityRepairStepList 验证场景定义
    public function sceneGetEntityRepairStepList()
    {
        return $this->append('param.current_task_id', 'require|integer')
            ->append('param.want_repair_entity_id', 'require|integer');
    }
}
